/*
 * Marker.cpp
 *
 *  Created on: 11/lug/2014
 *      Author: va2013
 */

#include "Marker.h"

Marker::Marker(int size, double meanValue) {
	this->regions = new vector<Rect>(size);
	this->meanValue = meanValue;

}

Marker::~Marker() {
	regions->clear();
	delete regions;
}

void Marker::setRegion(int index, Rect roi) {

	regions->at(index) = roi;
//	cout << "post set"<<endl;

}

Rect Marker::getRegion(int index) {
	return regions->at(index);
}

Rect Marker::getTotalROI() {
	int size = this->getRegionsSize();
	int top = regions->at(0).y;
	int bottom = regions->at(size - 1).y
			+ regions->at(size - 1).height;
	int left = INF;
	int right = 0;
	for (int i = 0; i < size; i++) {
		//ricerca left e right del buonding box complessivo
		int rectLeft = regions->at(i).x;
		int rectRight = regions->at(i).x
				+ regions->at(i).width;
		if (rectLeft < left)
			left = rectLeft;
		if (rectRight > right)
			right = rectRight;
	}
	return Rect(left, top, right - left, bottom - top);
}

int Marker::getRegionsSize() {
	return regions->size();
}

double Marker::getMeanValue() {
	return this->meanValue;
}

void Marker::setMeanValue(double mean) {
	this->meanValue = mean;
}
